# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lucene++
pkgver=3.0.8
pkgrel=7
pkgdesc="C++ port of the popular Java Lucene library"
url="https://github.com/luceneplusplus/LucenePlusPlus"
arch="all"
license="LGPL-3.0-or-later OR Apache-2.0"
depends_dev="boost-dev zlib-dev"
makedepends="$depends_dev cmake linux-headers samurai"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/luceneplusplus/LucenePlusPlus/archive/rel_3.0.8.tar.gz
	160.patch
	161.patch
	162.patch
	163.patch
	gcc11.patch
	"
builddir="$srcdir/LucenePlusPlus-rel_$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_CXX_FLAGS='-DBOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT' \
		-DCOTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH=/usr/include/fortify
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove vendored gtest that lucene++'s buildsystem insists on installing
	# together with it
	rm -rf "$pkgdir"/usr/include/gmock
	rm -rf "$pkgdir"/usr/include/gtest

	rm -rf "$pkgdir"/usr/lib/cmake/GTest

	rm -rf "$pkgdir"/usr/lib/libgmock*
	rm -rf "$pkgdir"/usr/lib/libgtest*

	rm -rf "$pkgdir"/usr/lib/pkgconfig/gmock*
	rm -rf "$pkgdir"/usr/lib/pkgconfig/gtest*
}

sha512sums="
fdc4ce5d55b05d8a1fa62bf749e2e428b8beec66847524f632b806d10ec7c969ca7d3c556804d2ce4b7cdf05db4f3c5613bde41aae53df9fe574d3046d448bf1  lucene++-3.0.8.tar.gz
76f8a8b29902f654c247ce025d3682ed828ff962143c333f36fabdaacc19fd94a8316e2f8418f7bd52a896bc7df24bf29209a68addc5521d3113e6c5bd817a95  160.patch
ca8d2d413a1ceb5387f8f9163503fe29adb746a2b2dba4cf923e7d69365322a2be64a7a69bcc9bdd9988f5632ef02390bd34cb53c2452d7c95ce53ddf9a86b76  161.patch
79936f34024701c65064eb6043ebddb05a7453fbc4d323487595eb75c9573eb999ae1e9c6b48c55ea4477b52bf24a914218250a8ab8423ba0c22be93ed97aa3f  162.patch
4332bd418f81675ad17f9e8e91831031100c04f19f676a501e06a69c086e69dbe348b82a89f8d79aba165f0bff29837184902c82d5e0e547de4603c4b27d1ab8  163.patch
c2c13c98495fce3f6c7a92e6d08ceb503e585c83f048ca1023763fe283fca0f4be56e793b0f57b56602f68f9a45d6798b1a7f09cfee7fd16430b3592bb8b7811  gcc11.patch
"
